<?php
	include "C:/xampp/htdocs/jrckeditor/db_edit/dbinfo.inc.php";
	$userid = $_GET['userid'];
	
	mysql_connect($hostname, $username, $password, FALSE);
	@mysql_select_db($database) or die("Unable to select database");
	
	$result = mysql_query('SELECT gid FROM ' . $conn_table . ' WHERE uid = ' . $userid);
	if (mysql_numrows($result) == 0) {
		echo "No documents for user id: " . $userid;
		return;
	}
	
	$query = 'SELECT * FROM ' . $doc_table . ' WHERE ';
	$i = 0;
	while ($row = mysql_fetch_array($result)) {
		if ($i != 0) {
			$query .= ' OR ';
		}
		$gid = $row['gid'];
		$query .= 'gid = ' . $gid;
		$i++;
	}
	
	$result = mysql_query($query);
	
	echo "<table border='1'>
<tr>
<th>id</th>
<th>gid</th>
<th>title</th>
<th>timestamp</th>
</tr>";
	while($row = mysql_fetch_array($result)) {
		echo "<tr>";
		echo "<td>" . $row['id'] . "</td>";
		echo "<td>" . $row['gid'] . "</td>";
		echo "<td>" . $row['title'] . "</td>";
		echo "<td>" . $row['timestamp'] . "</td>";
		echo "</tr>";
	}
	echo "</table>";
	
	mysql_close();

?>